﻿using System;
using System.Linq;
using System.Text;
using PersonalAccoutingProgram.Data;

namespace PersonalAccoutingProgram.Logic
{
    class ReferenceMaker
    {       

        protected static decimal CalculateAverageAmount(IQueryable<decimal> allAmounts)
        {
            int expensesCounter = 0;
            decimal expensesSum = 0;

            foreach (decimal currentStrAmount in allAmounts)
            {
                decimal amount = currentStrAmount;
                expensesSum += amount;
                expensesCounter++;
            }
            if (expensesCounter != 0)
            {
                decimal averageExpense =
                expensesSum / expensesCounter;
                return averageExpense;
            }
            else
            {
                return 0;
            }
        }

        protected static decimal CalculateSum(IQueryable<decimal> allExpenses)
        {
            decimal expensesSum = 0;

            foreach (decimal currentAmount in allExpenses)
            {
                decimal amount = currentAmount;
                expensesSum += amount;
            }

            return expensesSum;
        }
    }
}